import {
  HTTP
} from '../../utils/http.js'

module.exports = Behavior({
  behaviors: [],
  properties: {
   
  },
  data: {
    start: 1,
    count: 10,
    dataArray: [],
    empty:false,
    ending:true
  },

  methods: {
    setMoreData: function(dataArray) {
      this.data.ending = false
      if (dataArray==false) {
        this.data.ending = true
        if(this.data.dataArray==false){
          this.setData({
            empty:true
          })
        }
      }
      if (dataArray.length < this.data.count) {
        this.data.ending = true
      }
      let temp =this.data.dataArray.concat(dataArray)
      this.data.start += 1
      this.setData({
        dataArray: temp
      })
      return true
    },

    hasMore:function(){
      return !this.data.ending
    },

    getCurrentStart:function(){
      return this.data.start 
    },
    
    isFirstStart:function(){
      if (this.getCurrentStart() == 1) {
        return true
      }
      return false
    },

    initPagination:function(){
      this.data.ending = false
      this.data.start = 1
      this.data.dataArray = []
      this.setData({
        dataArray:[]
      })
    }
  }
})
